<template>
  <view class="content">
    <button size="mini" style="margin-top: 10px;" @click="openNewWindow">打开新的webview测试</button>
    <button size="mini" style="margin-top: 10px;" @click="callUniCloud">调用unicloud函数测试</button>
    <button size="mini" type="warn" style="margin-top: 10px;" @click="requestApi(1)">https-请求接口测试
    </button>
    <button size="mini" type="warn" style="margin-top: 10px;" @click="requestApi(2)">http-请求接口测试</button>
    <button size="mini" type="primary" style="margin-top: 10px;" @click="renderTest">renderjs</button>
<!--    <button size="mini" type="primary" style="margin-top: 10px;" @click="chatTest">chat</button>-->
    <button size="mini" type="primary" style="margin-top: 10px;" @click="dxYzmTest">顶象验证码校验</button>
    <button size="mini" type="primary" style="margin-top: 10px;" @click="tencentTest">腾讯验证码校验</button>
    <button size="mini" type="primary" style="margin-top: 10px;" @click="voiceTest">语言聊天测试</button>
    <button size="mini" type="primary" style="margin-top: 10px;" @click="photoTest">图片压缩测试</button>
  </view>
</template>

<script>
import "../../static/openjsbridge.icity.js"
import _axios from "../../plugin/axios";

export default {
  name: "other",
  methods: {
    openNewWindow() {
      iCityBridge.openWebView({
        title: 'baidu',
        url: 'https://www.baidu.com/',
        isShowTopTitle: '' //0:隐藏标题栏，1:显示标题栏
      });
    },
    callUniCloud() {
      uni.showLoading({
        title: '加载中',
      })
      uniCloud.callFunction({
        name: 'com-power',
        data: {
          action: 'request',
          request: {}
        },
        success: res => {
          console.log("com-power", res)
          uni.hideLoading()
        },
        fail: err => {
          console.error(err)
          uni.hideLoading()
        }
      })
    },
    requestApi(type = 1) {
      //ios 手机测试：http的接口请求失败
      let url = ''
      if (type == 1) url = 'https://67dcfd0c-c143-49dd-81a6-3d6aabd6ef7b.bspapp.com/api-request'
      if (type == 2) url = 'http://mdej.impc.com.cn/hlwyy/business-ggfw/communal/getToken'
      _axios({
        url: url,
        method: 'get',
        withCredentials: false,
      }).then(res => {
        console.log("requestApi", res)
      }).catch(err => {
        console.error("requestApi", err)
      })
    },
    requestApi2(type) {
      let url = ''
      if (type == 1) url = 'https://67dcfd0c-c143-49dd-81a6-3d6aabd6ef7b.bspapp.com/api-request'
      if (type == 2) url = 'http://mdej.impc.com.cn/hlwyy/business-ggfw/communal/getToken'
      uni.request({
        url,
        method: 'GET',
        success: res => {
          console.log("requestApi", res)
        },
        fail: err => {
          console.error("requestApi", err)
        }
      })
    },
    renderTest(){
      uni.navigateTo({
        url: '/pages/render/render'
      })
    },
    chatTest(){
      uni.navigateTo({
        url: '/pages/chat/chat'
      })
    },
    dxYzmTest(){
      uni.navigateTo({url:'/pages/captcha/dingxiang'})
    },
    tencentTest(){
      uni.navigateTo({url:'/pages/captcha/tencent'})
    },
    voiceTest(){
      uni.navigateTo({url:'/pages/chat/voice'})
    },
    photoTest(){
      uni.navigateTo({url:'/pages/photo/photo'})
    }
  }
}
</script>

<style scoped>
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
</style>
